from model.car_info import *
from model.vip import *
from model.total import *
from model.order import *

# 继承车辆信息类
class Stats_car_info(Car_info):
    #统计车辆累计信息
    @staticmethod
    def count_car_info():
        relust=g.db_session.query(Car_info).count()
        return relust
    #查询car_number车牌号字段的全部数据
    @staticmethod
    def count_province_number():
        query=g.db_session.query(Car_info.car_number).all()
        return query

# 继承总金额类
class Stats_total(Total):
    # 统计总金额
    @staticmethod
    def stats_total_money():
        # 查询并对 money 字段进行求和
        total_money = g.db_session.query(func.sum(Total.money)).scalar()
        # 如果返回值为 None，则将结果设置为 0
        if total_money is None:
            total_money = 0
        return total_money

#继承vip类
class Stats_vip(Vip):
    # 统计累计开通vip数量
    @staticmethod
    def count_vip():
        relust=g.db_session.query(Vip).count()
        return relust

# 继承订单类
class Stats_order(Order):
    @staticmethod
    def count_order():
        relust = g.db_session.query(Order).count()
        return relust
